/**
 * 
 */
package lv.pig.base.shiro;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.Session;
import org.apache.shiro.subject.Subject;

/**
 * @author chenbo
 * 
 */
public class ShiroUtils
{
    public static ShiroUser getUser()
    {
        return (ShiroUser)SecurityUtils.getSubject().getPrincipal();
    }
    
    public static Long getUserId()
    {
        return getUser().getId();
    }
    
    public static String getUserLoginName()
    {
        return getUser().getLoginName();
    }
    
    public static String getUserName()
    {
        return getUser().getUserName();
    }
    
    public static String getUserLoginIp()
    {
        Subject subject = SecurityUtils.getSubject();
        Session session = subject.getSession();
        return session.getHost();
    }
}
